﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ProjectCloth.WpfUI
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DataGrider dg = new DataGrider();
            dg.Show();

        }

        private void smSaleOrder_Click(object sender, RoutedEventArgs e)
        {
            //MessageBox.Show("剪货单!");
            var uc = new SaleOrderUc(0)
            {
                Width=950,
                Height=400
            };
            var tab = new TabItem()
            {
                Header = "剪货单",
                Content = uc,
                //Width=990
            };
            tabControlMenu.Items.Add(tab);
        }

        private void xlSaleOrder_Click(object sender, RoutedEventArgs e)
        {
            //MessageBox.Show("大货单!");
            var uc = new SaleOrderUc(1)
            {

                Width = 600,
                //HorizontalContentAlignment = HorizontalAlignment.Stretch, 
                Height = 300


            };
            var tab = new TabItem()
            {
                Header = "大货单",
                Content = uc,
                HorizontalContentAlignment = HorizontalAlignment.Stretch 
            };
            tabControlMenu.Items.Add(tab);
        }

        private void TabControlMenu_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var source = e.Source as TabControl;
            if(source!=null && source.SelectedIndex > 0)
            {
                var index = source.SelectedIndex;
                this.tabControlMenu.Items.RemoveAt(index);

            }
           
        }
    }
}
